package test4_1.demo01;

import java.util.ArrayList;
import java.util.Scanner;

public class Homework18_4 {
    public static void main(String[] args) {

        ArrayList<WorldCup> list = new ArrayList<>();
        list.add(new WorldCup(1930, "乌拉圭"));
        list.add(new WorldCup(1934, "意大利"));
        list.add(new WorldCup(1938, "意大利"));
        list.add(new WorldCup(1950, "乌拉圭"));
        list.add(new WorldCup(1954, "德国"));
        list.add(new WorldCup(1958, "巴西"));
        list.add(new WorldCup(1962, "巴西"));
        list.add(new WorldCup(1966, "英格兰"));
        list.add(new WorldCup(1970, "巴西"));
        list.add(new WorldCup(1974, "德国"));
        list.add(new WorldCup(1978, "阿根廷"));
        list.add(new WorldCup(1982, "意大利"));
        list.add(new WorldCup(1986, "阿根廷"));
        list.add(new WorldCup(1990, "德国"));
        list.add(new WorldCup(1994, "巴西"));
        list.add(new WorldCup(1998, "法国"));
        list.add(new WorldCup(2002, "巴西"));
        list.add(new WorldCup(2006, "意大利"));
        Scanner sc = new Scanner(System.in);
        System.out.println("输入年份：");
        int enterYear = sc.nextInt();
        int count = 0;
        for (WorldCup cup : list) {
            if (cup.getYear() == enterYear) {
                System.out.println("该年世界杯冠军是："+cup.getChampion());
                count++;
            }
        }
        if (count == 0) {
            System.out.println("该年没举办世界杯");
        }


        System.out.println("输入国家：");
        String enterChampion = sc.next();
        int count1 = 0;
        for (WorldCup cup : list) {
            if (cup.getChampion().equals(enterChampion)) {
                System.out.println("本国世界杯冠军在：" + cup.getYear() + "年");
                count1++;
            }
        }
        if (count1 == 0) {
            System.out.println("该国没在世界杯取得冠军");
        }

    }
}
